﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using yiCommerce.Core;
using yiCommerce.Service.FriendShips;

namespace yiCommerce.Controllers.api
{
    public class CreateFriendShipRequest
    {
        public int CustomerId { get; set; }
    }


    public class CreateFriendShipResult
    {
        public string Status { get; set; }
        public string Message { get; set; }
        public int Id { get; set; }
    }

    public class FriendShipApiController : ApiController
    {
        private IFriendShipService _friendShipService;
        private IWorkContext _workContext;

        public FriendShipApiController(IFriendShipService friendShipService, IWorkContext workContext)
        {
            _friendShipService = friendShipService;
            _workContext = workContext;
        }

        //关注
        public CreateFriendShipResult Create(CreateFriendShipRequest request)
        {

            var result = new CreateFriendShipResult();
            try
            {
                var toId = request.CustomerId;
                _friendShipService.CreateFriendShip(_workContext.CurrentCustomer.Id, toId);

                result.Status = "0";
            }
            catch (Exception e)
            {
                result.Status = "1";
                result.Message = e.Message;
            }
            return result;
        }
    }
}
